#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //disconnect
     button =new QPushButton(this);
    button->setText("请按按钮");
    connect(button,&QPushButton::clicked,this,&Widget::handle);
    //disconnect(button,&QPushButton::clicked,this,&Widget::handle);
    //lambda表达式可以简化我们的槽函数[](){},在方括号里面进行变量捕获
    connect(button,&QPushButton::clicked,this,[=](){
        qDebug()<<"lambda被执行了";
        button->move(300,400);
    });



}

Widget::~Widget()
{
    delete ui;
}

void  Widget::handle()
{
   if(button->text()==QString("请按按钮"))
   {
        button->setText("按钮按下了");
   }
   else
        button->setText("请按按钮");
}
